home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_force_blinding.cog < prev    next >
Text File  |  1998-02-25  |  6KB  |  248 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # FORCE_BLINDING.COG
  4. #
  5. # FORCEPOWER Script - Blinding
  6. #  Light Side Power
  7. #  Bin 27
  8. #
  9. # [YB]
  10. #
  11. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  12.  
  13.  
  14. symbols
  15.  
  16. thing       player                           local
  17. thing       victim                           local
  18. thing       potential                        local
  19.  
  20. flex        mana                             local
  21. flex        cost=100.0                       local
  22. flex        targetcost=5                     local
  23. flex        targetcount=0                    local
  24. int         rank                             local
  25. int         count                            local
  26. int         retval=0                         local
  27. int         dummy                            local
  28.  
  29. flex        dot                              local
  30. flex        maxDot                           local
  31.  
  32. sound       blindingSound=ForceBlind01.WAV   local
  33. template    cone_tpl=+force_blind            local
  34.  
  35. int         active=0                         local
  36.  
  37. int         inbubble=0                       local
  38.  
  39. message     startup
  40. message     activated
  41. message     deactivated
  42. message     pulse
  43. message     timer
  44. message     newplayer
  45. message     killed
  46. message     deselected
  47. message     selected
  48. message     enterbubble
  49. message     exitbubble
  50.  
  51. end
  52.  
  53. # ========================================================================================
  54.  
  55. code
  56.  
  57. startup:
  58.    player = GetlocalPlayerThing();
  59.    inbubble = 0;
  60.  
  61.    Return;
  62.  
  63. # ........................................................................................
  64.  
  65. activated:
  66.    if(inbubble) Return;
  67.  
  68.    if(active) Return;
  69.  
  70.    mana = GetInv(player, 14);
  71.    rank = GetInv(player, 27);
  72.  
  73.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  74.    {
  75.       victim = -1;
  76.       active = 1;
  77.       SetInvActivated(player, 27, 1);
  78.       SetPulse(0.33);
  79.    }
  80.  
  81.    Return;
  82.  
  83. # ........................................................................................
  84.  
  85. pulse:
  86.  
  87.    targetCount = targetCount + 1;
  88.    if(targetCount == 3)
  89.    {
  90.       if(GetInv(player, 64) != 1) ChangeInv(player, 14, -targetCost);
  91.       targetCount = 0;
  92.    }
  93.  
  94.    // Check all things for our victim.
  95.    victim = -1;
  96.    maxDot = 0;
  97.  
  98.    // Search for all players and actors.
  99.    potential = FirstThingInView(player, 30 + 15 * rank, 8, 0x404);
  100.    while(potential != -1)
  101.    {
  102.       if(
  103.          HasLOS(player, potential) &&
  104.          (potential != player) &&
  105.          (VectorDist(GetThingPos(player), GetThingPos(potential)) <= (1 + rank)) &&
  106.          !(GetThingFlags(potential) & 0x200) &&
  107.          !(GetActorFlags(potential) & 0x100) &&
  108.          !((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23)) &&
  109.          (jkGetBubbleDistance(potential) > 1.0)
  110.         )
  111.       {
  112.          dot = ThingViewDot(player, potential);
  113.          if(dot > maxDot)
  114.          {
  115.             victim = potential;
  116.             maxDot = dot;
  117.          }
  118.       }
  119.       potential = NextThingInView();
  120.    }
  121.  
  122.    // If we have a victim...
  123.    if(victim != -1)
  124.    {
  125.       jkSetTargetColors(1, 2, 3);
  126.       jkSetTarget(victim);
  127.    }
  128.    else
  129.    {
  130.       jkEndTarget();
  131.    }
  132.  
  133.    Return;
  134.  
  135. # ........................................................................................
  136.  
  137. deactivated:
  138.    if((victim == -1) || (GetThingHealth(player) <= 0) || inbubble)
  139.    {
  140.       call stop_power;
  141.       Return;
  142.    }
  143.  
  144.    SetPulse(0);
  145.    jkEndTarget();
  146.  
  147.    mana = GetInv(player, 14);
  148.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  149.    {
  150.       if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
  151.  
  152.       // Send a "force disturbance"...
  153.       if(!IsMulti())
  154.          SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 27, 0, 0, 0);
  155.  
  156.       SetBinWait(player, 27, 0.5);
  157.       rank = GetInv(player, 27);
  158.  
  159.       if(HasLOS(player, victim) && (victim != player))
  160.       {
  161.          PlayMode(player, 24);
  162.          PlaySoundThing(blindingSound, player, 1.0, -1, -1, 0x80);
  163.          dummy = CreateThingAtPosNR(cone_tpl, GetThingSector(player), VectorAdd(GetThingPos(player), '0.0 0.0 0.04'), '0.0 0.0 0.0');
  164.          SetThingLook(dummy, VectorSub(GetThingPos(victim), GetThingPos(player)));
  165.  
  166.          // Blind victim for 5 seconds per rank
  167.          if(GetThingType(victim) == 10)      // OTHER PLAYER
  168.          {
  169.             if(!(GetThingFlags(victim) & 0x200))
  170.                retval = SkillTarget(victim, player, 27, rank);
  171.          }
  172.          else                                // ENEMY
  173.          {
  174.             // If bit is already set we kill the existing timer and start a new one
  175.             if(GetActorFlags(victim) & 0x800) KillTimerEx(victim);
  176.             SetActorFlags(victim, 0x800);
  177.  
  178.             // Pass signature (i.e. unique ID) as a check in param 0
  179.             SetTimerEx(rank * 5, victim, GetThingSignature(victim), 0.0);
  180.          }
  181.       }
  182.    }
  183.  
  184.    active = 0;
  185.    SetInvActivated(player, 27, 0);
  186.  
  187.    Return;
  188.  
  189. # ........................................................................................
  190.  
  191. timer:
  192.    // This checks that the thing ref is still assigned to the same thing
  193.    // (remember the guy could have died and its ref reassigned to a generated thing)
  194.    if(GetThingSignature(GetSenderId()) == GetParam(0))
  195.    {
  196.       ClearActorFlags(GetSenderId(), 0x800);
  197.    }
  198.  
  199.    Return;
  200.  
  201. # ........................................................................................
  202.  
  203. selected:
  204.    jkPrintUNIString(player, 27);
  205.    Return;
  206.  
  207. # ........................................................................................
  208.  
  209. deselected:
  210.    call stop_power;
  211.  
  212.    Return;
  213.  
  214. # ........................................................................................
  215.  
  216. killed:
  217.    if(GetSenderRef() != player) Return;
  218.  
  219. newplayer:
  220.    call stop_power;
  221.    Return;
  222.  
  223. # ........................................................................................
  224.  
  225. enterbubble:
  226.    inbubble = 1;
  227.    call stop_power;
  228.    Return;
  229.  
  230. # ........................................................................................
  231.  
  232. exitbubble:
  233.    inbubble = 0;
  234.    Return;
  235.  
  236. # ........................................................................................
  237.  
  238. stop_power:
  239.    SetPulse(0);
  240.    SetInvActivated(player, 27, 0);
  241.    active = 0;
  242.    jkEndTarget();
  243.  
  244.    Return;
  245.  
  246. end
  247.  
  248.